<?php
/**
 * This file is part of webman.
 *
 * Licensed under The MIT License
 * For full copyright and license information, please see the MIT-LICENSE.txt
 * Redistributions of files must retain the above copyright notice.
 *
 * @author    walkor<walkor@workerman.net>
 * @copyright walkor<walkor@workerman.net>
 * @link      http://www.workerman.net/
 * @license   http://www.opensource.org/licenses/mit-license.php MIT License
 */

use Webman\Session\FileSessionHandler;
use Webman\Session\RedisSessionHandler;
use Webman\Session\RedisClusterSessionHandler;

$session_handle_list = [
    'file'          => FileSessionHandler::class,
    'redis'         => RedisSessionHandler::class,
    'redis_cluster' => RedisClusterSessionHandler::class,
];

return [

    'type' => env('SESSION_TYPE', 'file'), // or redis or redis_cluster

    'handler' => $session_handle_list[env('SESSION_TYPE','file')],

    'config' => [
        'file'          => [
            'save_path' => runtime_path() . '/sessions',
        ],
        'redis'         => [
            'host'     => env('REDIS_HOST','127.0.0.1'),
            'port'     => env('REDIS_PORT','6379'),
            'auth'     => env('REDIS_PASSWORD',''),
            'timeout'  => env('REDIS_TIMEOUT',2),
            'database' => env('REDIS_DATABASE',0),
            'prefix'   => env('APP_NAME','wm') . ':' . 'session' . ':',
        ],
        'redis_cluster' => [
            'host'    => explode(',', env('REDIS_CLUSTER_HOST', '')),
            'timeout' => env('REDIS_CLUSTER_TIMEOUT'),
            'auth'    => env('REDIS_CLUSTER_AUTH'),
            'prefix'  => env('APP_NAME', 'wm') . ':' . 'session' . ':',
        ]
    ],

    'session_name' => strtoupper(getenv('APP_NAME')) . '_SID',

    'auto_update_timestamp' => false,

    'lifetime' => 30 * 24 * 60 * 60,

    'cookie_lifetime' => 365 * 24 * 60 * 60,

    'cookie_path' => '/',

    'domain' => '',

    'http_only' => true,

    'secure' => false,

    'same_site' => '',

    'gc_probability' => [1, 1000],

];
